package com.starry.security.security;

import com.starry.utils.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class DefaultPasswordEncoder implements PasswordEncoder {
	public DefaultPasswordEncoder() {
		this(-1);
	}
	public DefaultPasswordEncoder(int s) {

	}
	//进行md5加密
	@Override
	public String encode(CharSequence charSequence) {

		return MD5.encrypt(charSequence.toString());
	}
	//对密码比对
	@Override
	public boolean matches(CharSequence charSequence, String encoderPassword) {
		return encoderPassword.equals(MD5.encrypt(charSequence.toString()));
	}

}
